Stockname = char(Stockname);
Indexname = char(Indexname);
[Stock Index Date PriceStock PriceIndex] = getStock_Index(Stockname,Indexname);
%Get the return of stock and index
rStock = PriceStock(2:end)./PriceStock(1:end-1) - 1;
rIndex = PriceIndex(2:end)./PriceIndex(1:end-1) - 1;

rolling = 260;
[n,m] = size(rStock);
k = n-rolling;
datan = x2mdate(Date,0);
datam=datan(262:end);

for i=1:k
    j=i+260
    rStockRobust = rStock(i:j,1);
    rIndexRobust = rIndex(i:j,:);
    [n,m] = size(rStockRobust);
    X = [ones(n,1),rIndexRobust];
    y = rStockRobust;
    betaRobust = MyLMSregor(y,X);
    betaRobust_Graph(i,:)=betaRobust(2,1);
end
%Output to Excel
ExcelRobust=[datam,betaRobust_Graph(:,2)];